var env = process.env;

var settings = {

    //全局设置
    globels: {
        host: process.env === 'development' ? '/ddl' : '/',
        data_prefix: 'common_admin_', //本地存储的key的前缀
    },

    //回调
    callbacks: {
        /**
         * ajax请求成功，返回的Result== false时调用
         */
        requestFail(data) {
            console.log(data)
            if (data.Result == false) {
                this.$alert(data.Msg, "提示", { confirmButtonText: '确定', type: 'error' })
            } else {}
        },

        /**
         * ajax请求网络出错时调用
         */
        requestError(err) {
            console.log(err)
            if (err.response && err.response.status == 404) {
                this.$alert('404错误', "提示", { confirmButtonText: '确定', type: 'error' })
            } else if (err.response && err.response.status == 500) {
                this.$alert('500错误，系统异常了', "提示", { confirmButtonText: '确定', type: 'error' })
            } else {
                let msg = '请求错误：' + (err.response ? err.response.status : '') + ',' + (err.response ? err.response.statusText : '')
                this.$alert(msg, "提示", { confirmButtonText: '确定', type: 'error' })
            }
        }
    }
};

var globels = settings.globels;
var callbacks = settings.callbacks;

export { globels, callbacks }